import pygame

class gate_part(pygame.sprite.Sprite):
    def __init__(self, uper, screen):
        print "Init! Gate!"
        super(gate_part, self).__init__(self.containers)
        self.uper = uper
        if uper:
            self.image = pygame.image.load("data/images/uper.png")
            self.rect  = self.image.get_rect()
            self.rect.bottom = screen.get_height() / 2.0
            self.rect.centerx = screen.get_width() / 2.0
            self.speed = 4
        else:
            self.image = pygame.image.load("data/images/lower.png")
            self.rect  = self.image.get_rect()
            self.rect.top = screen.get_height() / 2.0
            self.rect.centerx = screen.get_width() / 2.0
            self.speed = -4
            
        self.open = False
            
    def set_state(self, open):
        self.open = open
            
    def update(self):
        if self.open:
            self.rect.centery -= self.speed
        else:
            self.rect.centery += self.speed

    def draw(self, screen):
        screen.blit(self.image, self.rect)